本文整理汇总了Java中org.jdesktop.swingx.JXFrame.pack方法的典型用法代码示例。如果您正苦于以下问题:Java JXFrame.pack方法的具体用法?Java JXFrame.pack怎么用?Java JXFrame.pack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jdesktop.swingx.JXFrame
的用法示例。
在下文中一共展示了JXFrame.pack方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: interactiveRolloverHighlight
import org.jdesktop.swingx.JXFrame; //导入方法依赖的package包/类
/**
* Plain RolloverHighlighter.
* Issue #513-swingx: no rollover effect for disabled table.
*
*/
public void interactiveRolloverHighlight() {
final JXTable table = new JXTable(tableModel);
ColorHighlighter colorHighlighter = new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, Color.YELLOW, null);
table.addHighlighter(colorHighlighter);
Action action = new AbstractAction("toggle table enabled") {
@Override
public void actionPerformed(ActionEvent e) {
table.setEnabled(!table.isEnabled());
}
};
JXFrame frame = showWithScrollingInFrame(table, "rollover highlight, enabled/disabled table");
addAction(frame, action);
frame.pack();
}
示例2: interactiveTableCustomColorRendererWithHighlighterDontTouch
import org.jdesktop.swingx.JXFrame; //导入方法依赖的package包/类
/**
* Compare xtable using custom color renderer - standard vs. ext.<p>
* Adds highlighter which respects renderer's dont touch.
*/
public void interactiveTableCustomColorRendererWithHighlighterDontTouch() {
TableModel model = new AncientSwingTeam();
JXTable xtable = new JXTable(model);
Highlighter highlighter = createPropertyRespectingHighlighter(
HighlighterFactory.createSimpleStriping(HighlighterFactory.GENERIC_GRAY));
xtable.addHighlighter(highlighter);
xtable.setDefaultRenderer(Color.class, new ColorRenderer(true));
JXTable table = new JXTable(model);
table.addHighlighter(highlighter);
TableCellRenderer renderer = createColorRendererExt();
table.setDefaultRenderer(Color.class, renderer);
JXFrame frame = wrapWithScrollingInFrame(xtable, table, "JXTable/highlighter dont-touch: Custom color renderer - standard/ext");
addStatusMessage(frame, "Highlighter doesn't touch custom color renderer visual properties");
frame.pack();
frame.setVisible(true);
}
示例3: interactiveTableAndTreeCustomColorRenderingController
import org.jdesktop.swingx.JXFrame; //导入方法依赖的package包/类
/**
* xtable/xlist using the same custom component controller.<p>
*
*/
public void interactiveTableAndTreeCustomColorRenderingController() {
TableModel tableModel = new AncientSwingTeam();
ComponentProvider<JLabel> controller = createColorRenderingLabelController();
JXTable xtable = new JXTable(tableModel);
xtable.setDefaultRenderer(Color.class, new DefaultTableRenderer(controller));
TreeModel model = createTreeColorModel();
JTree tree = new JTree(model);
ComponentProvider<?> wrapper = new WrappingProvider(controller); //;createColorRenderingLabelController());
TreeCellRenderer renderer = new DefaultTreeRenderer(wrapper);
tree.setCellRenderer(renderer);
JXFrame frame = wrapWithScrollingInFrame(xtable, tree, "JXTable/JXTree: Custom color renderer - sharing the component controller");
addMessage(frame, "share provider in table and in wrappingProvider does not work?");
frame.pack();
frame.setVisible(true);
}
示例4: interactiveIconPainterHighlight
import org.jdesktop.swingx.JXFrame; //导入方法依赖的package包/类
/**
* Use highlighter with background image painter. Shared by table and list.
*/
public void interactiveIconPainterHighlight() throws Exception {
TableModel model = new AncientSwingTeam();
JXTable table = new JXTable(model);
ComponentProvider<JLabel> controller = new LabelProvider(
JLabel.RIGHT);
table.getColumn(0).setCellRenderer(
new DefaultTableRenderer(controller));
final ImagePainter imagePainter = new ImagePainter(XTestUtils.loadDefaultImage());
HighlightPredicate predicate = new ColumnHighlightPredicate(0);
Highlighter iconHighlighter = new PainterHighlighter(predicate, imagePainter );
Highlighter alternateRowHighlighter = HighlighterFactory.createSimpleStriping();
table.addHighlighter(alternateRowHighlighter);
table.addHighlighter(iconHighlighter);
// re-use component controller and highlighter in a JXList
JXList list = new JXList(createListNumberModel(), true);
list.setCellRenderer(new DefaultListRenderer(controller));
list.addHighlighter(alternateRowHighlighter);
list.addHighlighter(iconHighlighter);
list.toggleSortOrder();
final JXFrame frame = showWithScrollingInFrame(table, list,
"image highlighting plus striping");
frame.pack();
}
示例5: testMonthHeaderBoundsAtLocation
import org.jdesktop.swingx.JXFrame; //导入方法依赖的package包/类
/**
* coordinate mapping: monthBounds in pixel.
*
*/
@Test
public void testMonthHeaderBoundsAtLocation() {
// This test will not work in a headless configuration.
if (GraphicsEnvironment.isHeadless()) {
LOG.fine("cannot run test - headless environment");
return;
}
JXMonthView monthView = new JXMonthView();
monthView.setTraversable(true);
JXFrame frame = new JXFrame();
frame.add(monthView);
frame.pack();
BasicMonthViewUI ui = (BasicMonthViewUI) monthView.getUI();
Rectangle monthBoundsLToR = ui.getMonthHeaderBoundsAtLocation(20, 20);
assertEquals("", ui.getMonthHeaderHeight(), monthBoundsLToR.height);
}
示例6: getRealizedMonthViewUI
import org.jdesktop.swingx.JXFrame; //导入方法依赖的package包/类
/**
* Returns the ui of a realized JXMonthView with
* given componentOrientation and showingWeekNumbers flag.
* It's prefColumns/Rows are set to 2. The first displayedDate is
* 20. Feb. 2008 (to have fixed leading/trailing dates)
*
* The frame is packed and it's size extended by 40, 40 to
* give a slight off-position (!= 0) of the months shown.
*
* NOTE: this must not be used in a headless environment.
*
* @param co the componentOrientation to use
* @return
*/
private BasicMonthViewUI getRealizedMonthViewUI(ComponentOrientation co,
boolean isShowingWeekNumbers) {
JXMonthView monthView = new JXMonthView();
monthView.setPreferredColumnCount(2);
monthView.setPreferredRowCount(2);
monthView.setComponentOrientation(co);
monthView.setShowingWeekNumber(isShowingWeekNumbers);
Calendar calendar = monthView.getCalendar();
calendar.set(2008, Calendar.FEBRUARY, 20);
monthView.setFirstDisplayedDay(calendar.getTime());
JXFrame frame = new JXFrame();
frame.add(monthView);
frame.pack();
frame.setSize(frame.getWidth() + 40, frame.getHeight() + 40);
frame.setVisible(true);
BasicMonthViewUI ui = (BasicMonthViewUI) monthView.getUI();
return ui;
}
示例7: testGetDayAtLocation
import org.jdesktop.swingx.JXFrame; //导入方法依赖的package包/类
/**
* cleanup date representation as long: new api getDayAtLocation. will
* replace getDayAt which is deprecated as a first step.
*/
@Test
public void testGetDayAtLocation() {
// This test will not work in a headless configuration.
if (GraphicsEnvironment.isHeadless()) {
LOG.fine("cannot run test - headless environment");
return;
}
JXMonthView monthView = new JXMonthView();
monthView.getSelectionModel().setMinimalDaysInFirstWeek(1);
JXFrame frame = new JXFrame();
frame.add(monthView);
frame.pack();
Dimension pref = monthView.getPreferredSize();
pref.width = pref.width / 2;
pref.height = pref.height / 2;
Date date = monthView.getDayAtLocation(pref.width, pref.height);
assertNotNull(date);
}
示例8: getRealizedMonthViewUI
import org.jdesktop.swingx.JXFrame; //导入方法依赖的package包/类
/**
* Returns the ui of a realized JXMonthView with
* given componentOrientation and showingWeekNumbers flag.
* It's prefColumns/Rows are set to 2. The first displayedDate is
* 20. Feb. 2008 (to have fixed leading/trailing dates)
*
* The frame is packed and it's size extended by 40, 40 to
* give a slight off-position (!= 0) of the months shown.
*
*
*
* NOTE: this must not be used in a headless environment.
*
* @param co the componentOrientation to use
* @return
*/
private BasicMonthViewUI getRealizedMonthViewUI(ComponentOrientation co,
boolean isShowingWeekNumbers) {
JXMonthView monthView = new JXMonthView();
monthView.setPreferredColumnCount(2);
monthView.setPreferredRowCount(2);
monthView.setComponentOrientation(co);
monthView.setShowingWeekNumber(isShowingWeekNumbers);
Calendar calendar = monthView.getCalendar();
calendar.set(2008, Calendar.FEBRUARY, 20);
monthView.setFirstDisplayedDay(calendar.getTime());
JXFrame frame = new JXFrame();
frame.add(monthView);
frame.pack();
frame.setSize(frame.getWidth() + 40, frame.getHeight() + 40);
frame.setVisible(true);
BasicMonthViewUI ui = (BasicMonthViewUI) monthView.getUI();
return ui;
}
示例9: interactiveTableAndListCustomColorRenderingController
import org.jdesktop.swingx.JXFrame; //导入方法依赖的package包/类
/**
* xtable/xlist using the same custom component controller.<p>
*
*/
public void interactiveTableAndListCustomColorRenderingController() {
TableModel tableModel = new AncientSwingTeam();
ComponentProvider<JLabel> controller = createColorRenderingLabelController();
JXTable xtable = new JXTable(tableModel);
xtable.setDefaultRenderer(Color.class, new DefaultTableRenderer(controller));
ListModel model = createListColorModel();
JXList list = new JXList(model);
ListCellRenderer renderer = new DefaultListRenderer(controller);
list.setCellRenderer(renderer);
JXFrame frame = wrapWithScrollingInFrame(xtable, list, "JXTable/JXList: Custom color renderer - sharing the component controller");
addMessage(frame, "share provider in normally in different comps is okay?");
frame.pack();
frame.setVisible(true);
}
示例10: getRealizedDatePicker
import org.jdesktop.swingx.JXFrame; //导入方法依赖的package包/类
/**
* @return
*/
protected JXDatePicker getRealizedDatePicker() {
JXFrame frame = new JXFrame();
final JXDatePicker picker = new JXDatePicker();
frame.add(new JTextField(10));
frame.add(picker);
frame.add(new JTextField(10));
frame.pack();
frame.setVisible(true);
return picker;
}
示例11: interactiveRenderingLabel
import org.jdesktop.swingx.JXFrame; //导入方法依赖的package包/类
/**
* Style.None - use case? Always invisible?
*/
public void interactiveRenderingLabel() {
JComponent box = Box.createVerticalBox();
final JXLabel label = new JXLabel("setup: ShapePainter with fillstyle none");
// fixed: NPE with null shape - but has default instead of null?
final ShapePainter styleNone = new ShapePainter();
styleNone.setStyle(ShapePainter.Style.NONE);
label.setBackgroundPainter(styleNone);
box.add(label);
final JXLabel label2 = new JXLabel("setup: default ShapePainter");
final ShapePainter painter = new ShapePainter();
label2.setBackgroundPainter(painter);
box.add(label2);
Action action = new AbstractActionExt("toggle painter visible") {
public void actionPerformed(ActionEvent e) {
styleNone.setVisible(!styleNone.isVisible());
painter.setVisible(!painter.isVisible());
label.repaint();
label2.repaint();
}
};
JXFrame frame = wrapInFrame(box, "renderer label with shape painter - fillstyle none");
addAction(frame, action);
frame.pack();
frame.setVisible(true);
}
示例12: interactiveSelectedItem
import org.jdesktop.swingx.JXFrame; //导入方法依赖的package包/类
/**
* SwingX issue #670. Fixed.
* <p>
* Ensure that programatically selecting an item from the list correctly updates the display.
*/
public void interactiveSelectedItem() {
final ComboBoxModel model = createComboBoxModel();
JXFrame frame = wrapInFrame(new JComboBox(model), "programatically select item");
addAction(frame, new AbstractAction("Select 9") {
public void actionPerformed(ActionEvent e) {
model.setSelectedItem(9);
}
});
frame.pack();
frame.setVisible(true);
}
示例13: showCalendarFrame
import org.jdesktop.swingx.JXFrame; //导入方法依赖的package包/类
/**
*
*/
public void showCalendarFrame() {
calendarFrame = new JXFrame("Calendar 2010");
calendarFrame.setName("calendar2010");
calendarFrame.setDefaultCloseOperation(JXFrame.DO_NOTHING_ON_CLOSE);
WindowListener l = new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
calendarFrame.removeWindowListener(this);
hideCalendarFrame();
}
};
calendarFrame.addWindowListener(l);
JXPanel calendar = new JXPanel();
calendar.setBackground(Color.WHITE);
Painter<?> painter = createBackgroundPainter();
calendar.setBackgroundPainter(painter);
JXMonthView monthView = new JXMonthView();
Calendar cal = monthView.getCalendar();
cal.set(Calendar.YEAR, 2010);
cal.set(Calendar.MONTH, Calendar.JANUARY);
monthView.setFirstDisplayedDay(cal.getTime());
monthView.setOpaque(false);
monthView.setPreferredColumnCount(3);
monthView.setPreferredRowCount(4);
// old style: set visual property with JXMonthView api
monthView.setDayForeground(Calendar.SUNDAY, Color.MAGENTA);
// <snip> Custom CalendarRenderingHandler
// new style: install a custom renderingHandler
// (as client property, because no public api support yet)
// which allows to add Highlighters
monthView.putClientProperty(DemoMonthViewUI.RENDERING_HANDLER_KEY,
createRenderingHandler());
// </snip>
DemoUtils.setSnippet("Custom CalendarRenderingHandler", monthView);
calendar.add(monthView);
calendarFrame.add(calendar);
Application application = Application.getInstance(Application.class);
if (application instanceof SingleFrameApplication) {
((SingleFrameApplication) application).show(calendarFrame);
} else {
calendarFrame.pack();
calendarFrame.setLocationRelativeTo(this);
calendarFrame.setVisible(true);
}
}